CDF Development in Mathematica 9

Ian Hojnicki

User Interface Architect - User Interface Group

Developer Difficulities with CDF in Mathematica 8.0

I have content, what do I do next?

This works in Mathematica, why does it not work in ...?

Why does this gray box?

Why Did This Gray Box?

Just Say No.... To Gray Boxes

A Sandbox for Everyone!*

Introduced with the v8 web browser plugin

Restricts file system access

Prevents starting external processes

Restricts communicating with other processes

CDF Player uses the sandbox exclusively

Clear

SetOptions/CurrentValue

CopyToClipboard

*The Fine Print

Mathematica and Player Pro do not use the sandbox, so they still have the security system enabled(RowDefault[(, ]))

Notebooks, NotebookCreate, NotebookPut, etc ... are not as useful to completely useless.

SetOptions[$FrontEnd/$FrontEndSession/$DefaultFrontEnd, ..] or CurrentValue[...] = <something> is prohibited.

Testing Content for Multiple Environments

In v8, there were three products to worry about:

({{, , }, {CDF Player, Player Pro, Mathematica}})

And for every product there were two operating modes

Desktop App

Web Browser

Testing Content for Multiple Environments

In v9: testing is a lot easier

({{, }, {CDF Player, Player Pro}})

Previewing in CDF Player & Player Pro

Located under File >> CDF Preview

Provides a quick and convenient way to "sanity check" your content for CDF Player or Player Pro

Potential pitfalls

Packages available in Mathematica will appear to be available in CDF Player/Player Pro

$FrontEndSession/$DefaultFrontEnd/$FrontEnd are not reset to CDF Player/Player Pro defaults

Example: ({{MouseOver}})

Initialization Without Initialization Cells...

In CDF Player, the user *CAN NOT* evaluate anything.  So...

Manipulate

func[x_]:= (x^2)
Manipulate[Plot[Sin[func[x] a], {x,0,2π}], {{a,4},0,10}, SaveDefinitions->True]

DynamicModule (New in v9)

func[x_]:= (x^2)
DynamicModule[{a=4}, Panel@Column[{Slider[Dynamic[a], {0,10}],Dynamic@Plot[Sin[func[x] a], {x,0,2π}, ImageSize->{300,200}]}],SaveDefinitions->True]

Example:MouseOver

The CDF Deployment Wizard

Two basic ways to deploy your content

Standalone

Examples: Papers, Presentations, Tools, Applications

CDFDeploy["file.cdf",expr, Method->"Standalone"]

Embeddable

Examples: Demonstrations, Pods in Wolfram|Alpha, Blog entries

CDFDeploy["file.cdf",expr]

What does it actually do?

Takes your content and applies a set of modifications to ensure a desirable experience for end users.

Runtime Integrity (Evaluator/CellContext)

Usability Integrity (Deployed/Visible/WindowMargins)

Provides some additional information for embedding your content into a web page

<script type="text/javascript" src="http://www.wolfram.com/cdf-player/plugin/v2.1/cdfplugin.js" >< /script >
< script type = "text/javascript" > var cdf = new cdfplugin ();
cdf.embed ('"file.cdf"’,"width", "height");
</script>

An Example

Questions?

Recommended Talks

FrontEnd Keynote
John Fultz
Thursday 9:00 AM

Mobile Deployment
Rob Raguet-Schofield 
Thursday 10:00 AM

Deploying CDF Workshop
Yu-Sung Chang
Thursday 11:00 AM

Manipulate Secrets Revealed : Everything You Never Knew You Didn' t Know about Manipulate
Lou D'Andria
Friday 2:30 PM